home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
TPUG - Toronto PET Users Group
/
TPUG Users Group CD
/
TPUG Users Group CD.iso
/
AMIGA
/
AMICUS
/
AMICUS04.ADF
/
C
/
bobtest.c
< prev
next >
Wrap
C/C++ Source or Header
|
1985-10-30
|
6KB
|
200 lines
/* bobtest.c simple bobs test program v1.0 */
/****************************************************************
* *
* Copyright 1985, Commodore Amiga Inc. All rights reserved. *
* No part of this program may be reproduced, transmitted, *
* transcribed, stored in retrieval system, or translated into *
* any language or computer language, in any form or by any *
* means, electronic, mechanical, magnetic, optical, chemical, *
* manual or otherwise, without the prior written permission of *
* Commodore Amiga Incorporated, 983 University Ave, #D *
* Los Gatos, CA 95030 *
* *
****************************************************************/
/* PROGRAM TO PUT UP A BLOCK-BOB IN A WINDOW AND BOUNCE IT AROUND A BIT */
/* Author: Rob Peck 9/10/85 */
#include <exec/types.h>
#include <graphics/gfx.h>
#include <graphics/rastport.h>
#include <graphics/view.h>
#include <exec/exec.h>
#include <graphics/gels.h>
#include <intuition/intuition.h>
#define DEPTH 3
long GfxBase = 0;
long IntuitionBase=0;
struct Window *OpenWindow();
struct InputEvent *Intuition();
struct Screen *OpenScreen();
struct RastPort *CDRastPort();
struct Window *w;
struct Screen *screen;
struct RastPort *rp;
struct ViewPort *vp;
struct TextAttr TestFont = { "topaz.font", 9, 0, 0 };
struct NewScreen ns = {
0, 0, /* start position */
320, 200, DEPTH,
0, 1, /* detail pen, block pen */
0, /* viewing mode (was HIRES) */
CUSTOMSCREEN, /* screen type */
&TestFont, /* font to use */
"Gels Test Program", /* default title for screen */
NULL /* pointer to additional gadgets */
};
#define WINDOWFLAGS (GIMMEZEROZERO|WINDOWDRAG|WINDOWSIZING|WINDOWDEPTH|WINDOWCLOSE)
struct NewWindow nw = {
20, 20, /* start position */
220, 150, /* width, height */
-1, -1, /* detail pen, block pen */
0,
/* IDCMP flags */
WINDOWFLAGS,
/* window flags */
NULL, /* pointer to first user gadget */
NULL, /* pointer to user checkmark */
"Big Bob", /* window title */
NULL, /* pointer to screen (later) */
NULL, /* pointer to superbitmap */
10,10,300,160, /* sized window */
CUSTOMSCREEN /* type of screen in which to open */
};
main()
{
GfxBase = OpenLibrary("graphics.library", 0);
if (GfxBase == NULL)
{
printf("Unable to open graphics library\n");
exit(1000);
}
IntuitionBase = OpenLibrary("intuition.library", 0);
if (IntuitionBase == NULL)
{
printf("Unable to open intuition library\n");
exit(1000);
}
screen = OpenScreen(&ns);
nw.Screen = screen;
w = OpenWindow(&nw); /* open a window */
rp = w->RPort;
vp = &w->WScreen->ViewPort;
test2();
}
struct VSprite s1, s2; /* dummy sprites for gels list */
struct GelsInfo gelsinfo; /* gelsinfo to link into system rastport */
struct collTable collisiontable;
struct VSprite v;
struct Bob b;
SHORT i;
SHORT collmask[5 * 42];
SHORT borderline[5];
SHORT savebuffer[5 * 42 * 3];
SHORT dummy[ 1 * 42 * 3 ]; /* in case for some reason system needs
* one extra word per line to properly
* perform the save
*/
SHORT xspeed;
SHORT yspeed;
SHORT *images;
test2()
{
SHORT *j;
gelsinfo.nextLine = NULL;
gelsinfo.lastColor = NULL;
gelsinfo.collHandler = &collisiontable;
InitGels(&s1, &s2, &gelsinfo);
rp->GelsInfo = &gelsinfo;
xspeed = 2;
yspeed = 4;
v.X = 20;
v.Y = 20;
v.Flags = OVERLAY | SAVEBACK;
v.Height = 42; /* 42 lines high */
v.Width = 5; /* 5 words per row is 80 bits */
v.Depth = 3; /* 3 planes deep, will use same for
* its playfield */
v.MeMask = 1;
v.HitMask = 1;
/* HERE SET VALUE OF IMAGE TO THE PROPER AREA OF THE LOADED DATA */
images = (SHORT *)AllocMem(32000, MEMF_PUBLIC + MEMF_CLEAR);
j = images;
for(i=0; i< 16000; i++)
*j++ = 0xaa3c;
v.ImageData = (images + 20);
v.CollMask = &collmask[0];
v.BorderLine = &borderline[0];
InitMasks(&v);
v.PlanePick = 0x07; /* pick 3 planes */
v.PlaneOnOff = 0x0; /* all zeros to others if any */
/* ****************** now initialize the Bob variables ******* */
b.Flags = 0;
b.SaveBuffer = &savebuffer[0]; /* show where to save background */
b.ImageShadow = &collmask[0]; /* collision and shadow are same */
b.Before = NULL; /* dont care about drawing order */
b.After = NULL;
b.BobComp = NULL; /* not animation component */
b.DBuffer = NULL; /* not double buffered */
b.BobVSprite = &v; /* link them together */
v.VSBob = &b;
AddBob(&b, rp);
SortGList(rp);
WaitTOF();
DrawGList(rp,vp);
for(;;)
{
b.BobVSprite->Y += yspeed;
if(b.BobVSprite->Y > 100 || b.BobVSprite->Y < 10)
yspeed = -yspeed;
b.BobVSprite->X += xspeed;
if(b.BobVSprite->X > 100 || b.BobVSprite->X < 10)
xspeed = -xspeed;
SortGList(rp);
WaitTOF();
WaitTOF();
DrawGList(rp,vp);
}
return;
} /* end of test2 */